package com.qg.controller;

import com.qg.dto.ReturnResult;
import com.qg.pojo.QgUser;
import com.qg.service.LocaLqgUserService;
import com.qg.utils.EmptyUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

import static com.mysql.cj.MysqlType.JSON;

@Controller
@RequestMapping("/api")
public class controller {
    @Resource
    private LocaLqgUserService locaLqgUserService;
    @RequestMapping(value ="/loginUser",method = RequestMethod.POST)
    @ResponseBody
    public String loginUsder(String phone,String password) throws Exception{
      QgUser qgUser=  locaLqgUserService.LoginUser(phone,password);
      if (EmptyUtils.isEmpty(qgUser)){
          return "用户登录失败";
      }
     String userJson=JSON.toJSONString(qgUser);
      return userJson;

    }
    @RequestMapping(value="/getGoods",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult getGoods(String toKen,String goodsId)throws  Exception{
        return locaLqgUserService.getGoods(toKen,goodsId);
    }
}

